package com.itheima.web.service.impl.ums;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.itheima.result.PageResult;
import com.itheima.result.ResultData;
import com.itheima.service.ums.UmsResourceService;
import com.itheima.vo.ums.UmsResource;
import com.itheima.web.mapper.ums.UmsResourceMapper;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired;

@DubboService
public class UmsResourceServiceImpl extends ServiceImpl<UmsResourceMapper, UmsResource> implements UmsResourceService {
    @Autowired
    private UmsResourceMapper umsResourceMapper;


    @Override
    public ResultData pageList(Integer categoryId, String nameKeyword, String urlKeyword, Integer pageNum, Integer pageSize) {
        Page<UmsResource> infoPage=new Page<>(pageNum,pageSize);
        LambdaQueryWrapper<UmsResource> lqw=new LambdaQueryWrapper<>();
        lqw.like(nameKeyword !=null,UmsResource::getName,nameKeyword);
        lqw.like(urlKeyword !=null,UmsResource::getUrl,urlKeyword);
        lqw.like(categoryId!=null,UmsResource::getCategoryId,categoryId);
        this.page(infoPage,lqw);
        return ResultData.ok("操作成功", PageResult.init(infoPage.getTotal(),pageNum.longValue(),pageSize.longValue(),infoPage.getRecords()));
    }
}
